#@layoutUser()
#define mainUser()

<div style="float: right;width: 960px">
   	<fieldset class="layui-elem-field layui-field-title">
	  <legend>评论管理</legend>
	</fieldset>
    <div>
	    <div style="padding-top: 20px"></div>
	    <div>
		   <table class="layui-hide" id="commentListTable"></table>
	    </div>
	</div>
</div>

#end

#define js()

<script>
layui.use(['element','form','table'], function(){
    var form=layui.form;
	  var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
	  $ = layui.jquery; // 使用jquery
	  table = layui.table;
	  
	  table.render({
		    elem: '#commentListTable'
		    ,url:'/comment/commentListTable'
		    ,cols: [[
			  {field:'cid', width:80, title: '编号', sort: true,align:'center'}
			  ,{field:'content', title: '评论内容'}
			  ,{field:'name', width:200, title: '评论帖子',templet:formatArticleName}
			  ,{field:'comment_date', width:200, title: '评论日期', sort: true,align:'center'}
			  ,{field:'username', width:100, title: '评论用户'}
			  ,{field:'action', width:100, title: '操作',align:'center',templet:formatAction}
		    ]]
		    ,page: true
		  });
});
//删除评论
	function deleteOne(cid){
		layer.confirm('您确定要删除这条记录吗？', {
	      title:"系统提示"
		  ,btn: ['确定','取消'] //按钮
		}, function(){
			layer.closeAll('dialog');
			window.location.href="/comment/deleteComment/"+cid;
		}, function(){
		  
		});
	}

//文章跳转
function formatArticleName(d){
	return "<a href='/article/"+d.aid+"' target='_blank'>"+d.name+"</a>";
}
//右侧操作按钮
function formatAction(d){
	return "<button class='layui-btn layui-btn-warm layui-btn-xs' onclick='deleteOne("+d.cid+")'><i class='layui-icon layui-icon-delete' ></i>删除</button>";
}
</script>

#end